﻿'Quitado el botón borrar
Public Class FormBajaJugador

    Private _miCampeonato As Campeonato
    Private _idJugadorAEliminar As Integer

    Property idJugadoresAEliminar As Integer
        Get
            Return Me._idJugadorAEliminar
        End Get
        Set(value As Integer)
            Me._idJugadorAEliminar = value
        End Set
    End Property

    Private Sub FormBajaJugador_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = FormEntrada
        Me._miCampeonato = New Campeonato()
    End Sub

    Private Sub btnBajaDarBaja_Click(sender As Object, e As EventArgs) Handles btnBajaDarBaja.Click
        Dim camporelleno As Boolean = False

        If tbxBajaNIF.Text.Length = 0 Then
            ErrorProvider1.SetError(tbxBajaNIF, "Este campo no puede estar vacío")
        Else
            ErrorProvider1.SetError(tbxBajaNIF, Nothing)
            camporelleno = True
        End If

        If camporelleno = True Then
            Me._miCampeonato.eliminarJugador(tbxBajaNIF.Text, tbxBajaNombre.Text, _
                                             tbxBajaApellidos.Text, _idJugadorAEliminar) 'El id guardado en este formulario
            borrarFormulario()
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        FormBuscarJugadores.Show()
        FormBuscarJugadores.formDestino = "FormBajaJugador"
    End Sub

    Private Sub borrarFormulario()
        For Each control As Windows.Forms.Control In Me.Controls
            If TypeOf control Is GroupBox Then
                For Each controlText As Windows.Forms.Control In Me.GroupBox1.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
                For Each controlText As Windows.Forms.Control In Me.GroupBox2.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
                For Each controlText As Windows.Forms.Control In Me.GroupBox3.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
            End If
        Next
    End Sub

    Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
        Me.Close()
    End Sub
End Class